from typing import List
from datetime import datetime, date, time

from .Position import Position
from .Guarantee import Guarantee


class Flight:
    def __init__(self, id: int, 
            flight_no: str,             # 航班号
            flight_date: date,          # 航班日期
            estimated_time: datetime,   # 航班预计到达/出发时间
            normal_cnt: int,            # 普通旅客人数
            vip_cnt: int,               # VIP旅客人数
            priority: int,              # 航班优先级
            is_arr: bool,               # 航班是否是到达航班
            is_remote_stand: bool,      # 航班是否在远机位
            remote_stand: Position,     # 远机位信息
            arrival_gate: Position,     # 到达口信息
            boarding_gate: Position,    # 登机口信息
            raw_tasks: List[dict] = []  # json 任务列表
            ):   
        self._id = id
        self._flight_no = flight_no
        self._flight_date = flight_date
        self._estimated_time = estimated_time
        self._normal_cnt = normal_cnt
        self._vpn_cnt = vip_cnt
        self._priority = priority
        self._is_arr = is_arr
        self._is_remote_stand = is_remote_stand
        self._remote_stand = remote_stand
        self._arrival_gate = arrival_gate
        self._boarding_gate = boarding_gate
        self._raw_tasks = raw_tasks

    @property
    def raw_tasks(self):
        return self._raw_tasks

    @property
    def estimated_time(self):
        return self._estimated_time

    def __repr__(self):
        return f"Flight: {self._flight_no}({self._flight_date})"


class FlightTask:
    def __init__(self, 
            flight: Flight,                     # 航班
            guarantee_list: List[Guarantee],    # 本任务所服务的保障环节列表
            current_time: datetime):            # 派遣任务的当前时间，不延误的情况下，等于航班出发/到达时间
        self._flight = flight
        self._guarantee_list = guarantee_list
        self._current_time = current_time

    @property
    def delay_time(self):
        return self._current_time - self._flight._estimated_time
